<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <title>basicAuth</title>
    <script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
    <script>
        $(document).ready(function () {
            $.post("/common/getLoginUser", {}, function (response) {
                console.info(response);
                $("#pageInfo").html("欢迎登录" + response);
            });
        });

        function queryMobile() {
            $.get("/mobile/query", function (response) {
                alert(response);
            });
        }

        function querySalary() {
            $.get("/salary/query", function (response) {
                alert(response);
            });
        }

        function logout() {
            // 使用Ajax方式执行退出操作，确保完全清理会话
            $.ajax({
                url: '/logout',
                type: 'POST',
                success: function(result) {
                    // 清除所有可能的缓存
                    window.location.href = '/login.html?logout=' + new Date().getTime();
                },
                error: function(result) {
                    // 即使出错也跳转到登录页
                    window.location.href = '/login.html?logout=' + new Date().getTime();
                }
            });
        }
    </script>
</head>
<body>
    <div id="pageInfo">123</div>
    <button onclick="logout()">退出</button>
    <hr>
    <button onclick="queryMobile()" auth="mobile">查看电话号码</button>
    <button onclick="querySalary()" auth="salary">查看薪水</button>
    <hr>
    电话号码服务地址: http://localhost:8080/mobile/query <br>
    薪水服务地址: http://localhost:8080/salary/query
</body>
</html>